var mSecondsArray = new Array();
var isStartArray = new Array();
var idArray = new Array();

updateTimer();
var timerInterval = setInterval("updateTimer();", 1000);

function setTimer (mseconds, id) {

    var currentTime = new Date (mseconds - 3600000);

    var currentHours = currentTime.getHours ();
    var currentMinutes = currentTime.getMinutes ();
    var currentSeconds = currentTime.getSeconds ();

    currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
    currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

    // Compose the string for display
    var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;

    document.getElementById(id).innerHTML = currentHours + ":" + currentMinutes + ":" + currentSeconds;

}

function updateTimer () {
    for ( i = 0 ; i < idArray.length; i++) {
        if (isStartArray[i] == true) {
            setTimer (mSecondsArray[i], idArray[i]);
            mSecondsArray[i] += 1000;
        }
    }
}

function initTimerArray (mseconds, isstart, id) {
    for (var i = 0 ; i < idArray.length; i++) {
        if (idArray[i] == id) {
            mSecondsArray[i] = mseconds;
            isStartArray[i] = isstart;
            return;
        }
    }
    idArray[i] = id;
    mSecondsArray[i] = mseconds;
    isStartArray[i] = isstart;
    setTimer (mseconds, id);
}